<!DOCTYPE html>
<html lang="zh">
<head>
    <title>权限管理 - virus CMS</title>
    {include file="common/meta" /}
</head>
<body>

<!-- Navbar -->
{include file="common/header" /}
<!-- /Navbar -->
<!-- Main Container -->
<div class="main-container container-fluid">
    <!-- Page Container -->
    <div class="page-container">

        <!-- Page Sidebar -->
        {include file="common/sidebar" /}
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li class="active">
                        <i class="fa fa-home"></i>&nbsp;控制面板
                    </li>
                    <li>
                        <i class="fa fa-send"></i> 权限管理
                    </li>
                    <li>
                        <i class=""></i> 管理员列表
                    </li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->
            <!-- Page Body -->
            <div class="page-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">管理员列表</h3>
                            </div>
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-lg-2">
                                        {if condition="check_auth('Admin/create')"}
                                        <a href="{:url('Admin/create')}" class="btn btn-success">
                                            <i class="fa fa-plus"></i>添加管理员
                                        </a>
                                        {/if}
                                    </div>
                                </div>
                                <div class="row margin-top-5">
                                    <div class="col-sm-12">
                                        <table class="table table-bordered table-responsive table-hover">
                                            <thead>
                                            <tr>
                                                <th>#ID</th>
                                                <th>昵称</th>
                                                <th>用户名</th>
                                                <th>头像</th>
                                                <th>邮箱</th>
                                                <th>手机号码</th>
                                                <th>状态</th>
                                                <th>最后登录时间</th>
                                                <th>最后登录IP</th>
                                                <th>创建时间</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            {foreach $admins as $v}
                                            <tr>
                                                <td>{$v.id}</td>
                                                <td>{$v.nickname}</td>
                                                <td>{$v.username}</td>
                                                <td><img src="{$v.avatar}" style="width: 100px;height: 100px;" alt=""></td>
                                                <td>{$v.email}</td>
                                                <td>{$v.mobile}</td>
                                                <td>{$v.status}</td>
                                                <td>{$v.last_login_time}</td>
                                                <td>{$v.last_login_ip}</td>
                                                <td>{$v.create_time}</td>
                                                <td>
                                                    {if condition="$v.is_admin eq 1"}
                                                    超级管理员不能进行改动
                                                    {else /}

                                                    {if condition="check_auth('Admin/edit')"}
                                                    <a href="{:url('Admin/edit', array('id' => $v.id))}" class="btn btn-primary">
                                                        <i class="fa fa-edit"></i>编辑
                                                    </a>
                                                    {/if}
                                                    {if condition="check_auth('Admin/delete')"}
                                                    <a href="javascript:;" data-id="{$v.id}"
                                                       onclick="confirm_msg(this, '你确定要删除吗?');" class="btn btn-danger">
                                                        <i class="fa fa-trash"></i>删除
                                                    </a>
                                                    {/if}
                                                    {/if}
                                                </td>
                                            </tr>
                                            {/foreach}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->

    </div>
    <!-- /Page Container -->
    <!-- Main Container -->

</div>

{include file="common/script" /}
<script type="text/javascript">
    function confirm_msg(obj, msg = '') {
        var id = $(obj).attr('data-id');
        var url = "/admin/Admin/delete";
        confirm(msg, "你将失去这条数据", function (isConfirm) {
            if (isConfirm) {
                $.post(url, {id: id}, function (data) {
                    if (data.code === 1) {
                        alert(data.msg, ":)", function () {
                            setTimeout(function () {
                                location.href = '/admin/Admin/index';
                            }, 2000);
                        }, {type: 'success', confirmButtonText: 'OK'});
                    } else {
                        alert(data.msg, ":)", function () {
                            setTimeout(function () {
                                location.href = '/admin/Admin/index';
                            }, 2000);
                        }, {type: 'error', confirmButtonText: 'OK'});
                    }
                }, 'json');
            } else {
                return false;
            }
        }, {confirmButtonText: '确定', cancelButtonText: '取消', width: 400});
    }
</script>
</body>
<!--  /Body -->
</html>
